package com.google.android.gms.internal;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.VisibleForTesting;
import android.util.Log;
import android.util.Pair;
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;
import dalvik.system.DexClassLoader;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class zzdm {
    private static final String TAG = "zzdm";
    private volatile boolean zzahq = false;
    protected Context zzaiq;
    private ExecutorService zzair;
    private DexClassLoader zzais;
    private zzcx zzait;
    private byte[] zzaiu;
    private volatile AdvertisingIdClient zzaiv = null;
    private Future zzaiw = null;
    private boolean zzaix;
    /* access modifiers changed from: private */
    public volatile zzba zzaiy = null;
    private Future zzaiz = null;
    private zzcp zzaja;
    private boolean zzajb = false;
    private boolean zzajc = false;
    private Map<Pair<String, String>, zzes> zzajd;
    private boolean zzaje = false;
    /* access modifiers changed from: private */
    public boolean zzajf;
    private boolean zzajg;

    final class zza extends BroadcastReceiver {
        private zza() {
        }

        /* synthetic */ zza(zzdm zzdm, zzdn zzdn) {
            this();
        }

        public final void onReceive(Context context, Intent intent) {
            if ("android.intent.action.USER_PRESENT".equals(intent.getAction())) {
                boolean unused = zzdm.this.zzajf = true;
            } else if ("android.intent.action.SCREEN_OFF".equals(intent.getAction())) {
                boolean unused2 = zzdm.this.zzajf = false;
            }
        }
    }

    private zzdm(Context context) {
        boolean z = true;
        this.zzajf = true;
        this.zzajg = false;
        Context applicationContext = context.getApplicationContext();
        this.zzaix = applicationContext == null ? false : z;
        this.zzaiq = this.zzaix ? applicationContext : context;
        this.zzajd = new HashMap();
    }

    /* JADX WARNING: Can't wrap try/catch for region: R(18:1|2|(1:4)|5|6|7|8|(1:10)(1:11)|12|(1:14)(1:15)|16|17|18|(2:20|(2:22|23))|24|25|26|(3:27|28|(12:34|(1:36)|37|38|39|40|41|42|43|(2:45|(1:47)(1:48))|49|50)(2:32|33))) */
    /* JADX WARNING: Missing exception handler attribute for start block: B:17:0x0046 */
    /* JADX WARNING: Removed duplicated region for block: B:20:0x004f A[Catch:{ zzcy -> 0x015e, zzdj -> 0x0165 }] */
    /* JADX WARNING: Removed duplicated region for block: B:32:0x008b A[Catch:{ all -> 0x012b, FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }] */
    /* JADX WARNING: Removed duplicated region for block: B:34:0x0091 A[Catch:{ all -> 0x012b, FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }, PHI: r9 
      PHI: (r9v9 java.io.File) = (r9v8 java.io.File), (r9v15 java.io.File) binds: [B:29:0x007f, B:31:0x0089] A[DONT_GENERATE, DONT_INLINE]] */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static com.google.android.gms.internal.zzdm zza(android.content.Context r8, java.lang.String r9, java.lang.String r10, boolean r11) {
        /*
            com.google.android.gms.internal.zzdm r0 = new com.google.android.gms.internal.zzdm
            r0.<init>(r8)
            java.util.concurrent.ExecutorService r8 = java.util.concurrent.Executors.newCachedThreadPool()     // Catch:{ zzdj -> 0x0165 }
            r0.zzair = r8     // Catch:{ zzdj -> 0x0165 }
            r0.zzahq = r11     // Catch:{ zzdj -> 0x0165 }
            if (r11 == 0) goto L_0x001c
            java.util.concurrent.ExecutorService r8 = r0.zzair     // Catch:{ zzdj -> 0x0165 }
            com.google.android.gms.internal.zzdn r11 = new com.google.android.gms.internal.zzdn     // Catch:{ zzdj -> 0x0165 }
            r11.<init>(r0)     // Catch:{ zzdj -> 0x0165 }
            java.util.concurrent.Future r8 = r8.submit(r11)     // Catch:{ zzdj -> 0x0165 }
            r0.zzaiw = r8     // Catch:{ zzdj -> 0x0165 }
        L_0x001c:
            java.util.concurrent.ExecutorService r8 = r0.zzair     // Catch:{ zzdj -> 0x0165 }
            com.google.android.gms.internal.zzdp r11 = new com.google.android.gms.internal.zzdp     // Catch:{ zzdj -> 0x0165 }
            r11.<init>(r0)     // Catch:{ zzdj -> 0x0165 }
            r8.execute(r11)     // Catch:{ zzdj -> 0x0165 }
            r8 = 0
            r11 = 1
            com.google.android.gms.common.zzf r1 = com.google.android.gms.common.zzf.zzahf()     // Catch:{ Throwable -> 0x0046 }
            android.content.Context r2 = r0.zzaiq     // Catch:{ Throwable -> 0x0046 }
            int r2 = com.google.android.gms.common.zzf.zzcg(r2)     // Catch:{ Throwable -> 0x0046 }
            if (r2 <= 0) goto L_0x0036
            r2 = r11
            goto L_0x0037
        L_0x0036:
            r2 = r8
        L_0x0037:
            r0.zzajb = r2     // Catch:{ Throwable -> 0x0046 }
            android.content.Context r2 = r0.zzaiq     // Catch:{ Throwable -> 0x0046 }
            int r1 = r1.isGooglePlayServicesAvailable(r2)     // Catch:{ Throwable -> 0x0046 }
            if (r1 != 0) goto L_0x0043
            r1 = r11
            goto L_0x0044
        L_0x0043:
            r1 = r8
        L_0x0044:
            r0.zzajc = r1     // Catch:{ Throwable -> 0x0046 }
        L_0x0046:
            r0.zza((int) r8, (boolean) r11)     // Catch:{ zzdj -> 0x0165 }
            boolean r1 = com.google.android.gms.internal.zzds.zzas()     // Catch:{ zzdj -> 0x0165 }
            if (r1 == 0) goto L_0x0069
            com.google.android.gms.internal.zzny<java.lang.Boolean> r1 = com.google.android.gms.internal.zzoi.zzbrs     // Catch:{ zzdj -> 0x0165 }
            com.google.android.gms.internal.zzog r2 = com.google.android.gms.internal.zzlc.zzio()     // Catch:{ zzdj -> 0x0165 }
            java.lang.Object r1 = r2.zzd(r1)     // Catch:{ zzdj -> 0x0165 }
            java.lang.Boolean r1 = (java.lang.Boolean) r1     // Catch:{ zzdj -> 0x0165 }
            boolean r1 = r1.booleanValue()     // Catch:{ zzdj -> 0x0165 }
            if (r1 == 0) goto L_0x0069
            java.lang.IllegalStateException r8 = new java.lang.IllegalStateException     // Catch:{ zzdj -> 0x0165 }
            java.lang.String r9 = "Task Context initialization must not be called from the UI thread."
            r8.<init>(r9)     // Catch:{ zzdj -> 0x0165 }
            throw r8     // Catch:{ zzdj -> 0x0165 }
        L_0x0069:
            com.google.android.gms.internal.zzcx r1 = new com.google.android.gms.internal.zzcx     // Catch:{ zzdj -> 0x0165 }
            r2 = 0
            r1.<init>(r2)     // Catch:{ zzdj -> 0x0165 }
            r0.zzait = r1     // Catch:{ zzdj -> 0x0165 }
            com.google.android.gms.internal.zzcx r1 = r0.zzait     // Catch:{ zzcy -> 0x015e }
            byte[] r9 = r1.zzl(r9)     // Catch:{ zzcy -> 0x015e }
            r0.zzaiu = r9     // Catch:{ zzcy -> 0x015e }
            android.content.Context r9 = r0.zzaiq     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            java.io.File r9 = r9.getCacheDir()     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            if (r9 != 0) goto L_0x0091
            android.content.Context r9 = r0.zzaiq     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            java.lang.String r1 = "dex"
            java.io.File r9 = r9.getDir(r1, r8)     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            if (r9 != 0) goto L_0x0091
            com.google.android.gms.internal.zzdj r8 = new com.google.android.gms.internal.zzdj     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            r8.<init>()     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            throw r8     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
        L_0x0091:
            java.lang.String r1 = "1510898742191"
            java.io.File r3 = new java.io.File     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            java.lang.String r4 = "%s/%s.jar"
            r5 = 2
            java.lang.Object[] r6 = new java.lang.Object[r5]     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            r6[r8] = r9     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            r6[r11] = r1     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            java.lang.String r4 = java.lang.String.format(r4, r6)     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            r3.<init>(r4)     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            boolean r4 = r3.exists()     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            if (r4 != 0) goto L_0x00c2
            com.google.android.gms.internal.zzcx r4 = r0.zzait     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            byte[] r6 = r0.zzaiu     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            byte[] r10 = r4.zzb(r6, r10)     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            r3.createNewFile()     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            java.io.FileOutputStream r4 = new java.io.FileOutputStream     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            r4.<init>(r3)     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            int r6 = r10.length     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            r4.write(r10, r8, r6)     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            r4.close()     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
        L_0x00c2:
            r0.zzb((java.io.File) r9, (java.lang.String) r1)     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            dalvik.system.DexClassLoader r10 = new dalvik.system.DexClassLoader     // Catch:{ all -> 0x012b }
            java.lang.String r4 = r3.getAbsolutePath()     // Catch:{ all -> 0x012b }
            java.lang.String r6 = r9.getAbsolutePath()     // Catch:{ all -> 0x012b }
            android.content.Context r7 = r0.zzaiq     // Catch:{ all -> 0x012b }
            java.lang.ClassLoader r7 = r7.getClassLoader()     // Catch:{ all -> 0x012b }
            r10.<init>(r4, r6, r2, r7)     // Catch:{ all -> 0x012b }
            r0.zzais = r10     // Catch:{ all -> 0x012b }
            zzb(r3)     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            r0.zza((java.io.File) r9, (java.lang.String) r1)     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            java.lang.String r10 = "%s/%s.dex"
            java.lang.Object[] r3 = new java.lang.Object[r5]     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            r3[r8] = r9     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            r3[r11] = r1     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            java.lang.String r8 = java.lang.String.format(r10, r3)     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            zzm(r8)     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            com.google.android.gms.internal.zzny<java.lang.Boolean> r8 = com.google.android.gms.internal.zzoi.zzbrk     // Catch:{ zzdj -> 0x0165 }
            com.google.android.gms.internal.zzog r9 = com.google.android.gms.internal.zzlc.zzio()     // Catch:{ zzdj -> 0x0165 }
            java.lang.Object r8 = r9.zzd(r8)     // Catch:{ zzdj -> 0x0165 }
            java.lang.Boolean r8 = (java.lang.Boolean) r8     // Catch:{ zzdj -> 0x0165 }
            boolean r8 = r8.booleanValue()     // Catch:{ zzdj -> 0x0165 }
            if (r8 == 0) goto L_0x0121
            boolean r8 = r0.zzajg     // Catch:{ zzdj -> 0x0165 }
            if (r8 == 0) goto L_0x0106
            goto L_0x0121
        L_0x0106:
            android.content.IntentFilter r8 = new android.content.IntentFilter     // Catch:{ zzdj -> 0x0165 }
            r8.<init>()     // Catch:{ zzdj -> 0x0165 }
            java.lang.String r9 = "android.intent.action.USER_PRESENT"
            r8.addAction(r9)     // Catch:{ zzdj -> 0x0165 }
            java.lang.String r9 = "android.intent.action.SCREEN_OFF"
            r8.addAction(r9)     // Catch:{ zzdj -> 0x0165 }
            android.content.Context r9 = r0.zzaiq     // Catch:{ zzdj -> 0x0165 }
            com.google.android.gms.internal.zzdm$zza r10 = new com.google.android.gms.internal.zzdm$zza     // Catch:{ zzdj -> 0x0165 }
            r10.<init>(r0, r2)     // Catch:{ zzdj -> 0x0165 }
            r9.registerReceiver(r10, r8)     // Catch:{ zzdj -> 0x0165 }
            r0.zzajg = r11     // Catch:{ zzdj -> 0x0165 }
        L_0x0121:
            com.google.android.gms.internal.zzcp r8 = new com.google.android.gms.internal.zzcp     // Catch:{ zzdj -> 0x0165 }
            r8.<init>(r0)     // Catch:{ zzdj -> 0x0165 }
            r0.zzaja = r8     // Catch:{ zzdj -> 0x0165 }
            r0.zzaje = r11     // Catch:{ zzdj -> 0x0165 }
            return r0
        L_0x012b:
            r10 = move-exception
            zzb(r3)     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            r0.zza((java.io.File) r9, (java.lang.String) r1)     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            java.lang.String r2 = "%s/%s.dex"
            java.lang.Object[] r3 = new java.lang.Object[r5]     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            r3[r8] = r9     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            r3[r11] = r1     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            java.lang.String r8 = java.lang.String.format(r2, r3)     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            zzm(r8)     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
            throw r10     // Catch:{ FileNotFoundException -> 0x0157, IOException -> 0x0150, zzcy -> 0x0149, NullPointerException -> 0x0142 }
        L_0x0142:
            r8 = move-exception
            com.google.android.gms.internal.zzdj r9 = new com.google.android.gms.internal.zzdj     // Catch:{ zzdj -> 0x0165 }
            r9.<init>(r8)     // Catch:{ zzdj -> 0x0165 }
            throw r9     // Catch:{ zzdj -> 0x0165 }
        L_0x0149:
            r8 = move-exception
            com.google.android.gms.internal.zzdj r9 = new com.google.android.gms.internal.zzdj     // Catch:{ zzdj -> 0x0165 }
            r9.<init>(r8)     // Catch:{ zzdj -> 0x0165 }
            throw r9     // Catch:{ zzdj -> 0x0165 }
        L_0x0150:
            r8 = move-exception
            com.google.android.gms.internal.zzdj r9 = new com.google.android.gms.internal.zzdj     // Catch:{ zzdj -> 0x0165 }
            r9.<init>(r8)     // Catch:{ zzdj -> 0x0165 }
            throw r9     // Catch:{ zzdj -> 0x0165 }
        L_0x0157:
            r8 = move-exception
            com.google.android.gms.internal.zzdj r9 = new com.google.android.gms.internal.zzdj     // Catch:{ zzdj -> 0x0165 }
            r9.<init>(r8)     // Catch:{ zzdj -> 0x0165 }
            throw r9     // Catch:{ zzdj -> 0x0165 }
        L_0x015e:
            r8 = move-exception
            com.google.android.gms.internal.zzdj r9 = new com.google.android.gms.internal.zzdj     // Catch:{ zzdj -> 0x0165 }
            r9.<init>(r8)     // Catch:{ zzdj -> 0x0165 }
            throw r9     // Catch:{ zzdj -> 0x0165 }
        L_0x0165:
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.internal.zzdm.zza(android.content.Context, java.lang.String, java.lang.String, boolean):com.google.android.gms.internal.zzdm");
    }

    /* JADX WARNING: Can't wrap try/catch for region: R(10:20|21|22|23|24|25|26|27|28|30) */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:26:0x0091 */
    /* JADX WARNING: Removed duplicated region for block: B:39:0x00a3 A[SYNTHETIC, Splitter:B:39:0x00a3] */
    /* JADX WARNING: Removed duplicated region for block: B:43:0x00a8 A[SYNTHETIC, Splitter:B:43:0x00a8] */
    /* JADX WARNING: Removed duplicated region for block: B:52:0x00b2 A[SYNTHETIC, Splitter:B:52:0x00b2] */
    /* JADX WARNING: Removed duplicated region for block: B:56:0x00b7 A[SYNTHETIC, Splitter:B:56:0x00b7] */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private final void zza(java.io.File r8, java.lang.String r9) {
        /*
            r7 = this;
            java.io.File r0 = new java.io.File
            java.lang.String r1 = "%s/%s.tmp"
            r2 = 2
            java.lang.Object[] r3 = new java.lang.Object[r2]
            r4 = 0
            r3[r4] = r8
            r5 = 1
            r3[r5] = r9
            java.lang.String r1 = java.lang.String.format(r1, r3)
            r0.<init>(r1)
            boolean r1 = r0.exists()
            if (r1 == 0) goto L_0x001b
            return
        L_0x001b:
            java.io.File r1 = new java.io.File
            java.lang.String r3 = "%s/%s.dex"
            java.lang.Object[] r2 = new java.lang.Object[r2]
            r2[r4] = r8
            r2[r5] = r9
            java.lang.String r8 = java.lang.String.format(r3, r2)
            r1.<init>(r8)
            boolean r8 = r1.exists()
            if (r8 != 0) goto L_0x0033
            return
        L_0x0033:
            long r2 = r1.length()
            r5 = 0
            int r8 = (r2 > r5 ? 1 : (r2 == r5 ? 0 : -1))
            if (r8 > 0) goto L_0x003e
            return
        L_0x003e:
            int r8 = (int) r2
            byte[] r8 = new byte[r8]
            r2 = 0
            java.io.FileInputStream r3 = new java.io.FileInputStream     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00af, all -> 0x009f }
            r3.<init>(r1)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00af, all -> 0x009f }
            int r5 = r3.read(r8)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b0, all -> 0x009d }
            if (r5 > 0) goto L_0x0054
            r3.close()     // Catch:{ IOException -> 0x0050 }
        L_0x0050:
            zzb(r1)
            return
        L_0x0054:
            com.google.android.gms.internal.zzbe r5 = new com.google.android.gms.internal.zzbe     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b0, all -> 0x009d }
            r5.<init>()     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b0, all -> 0x009d }
            java.lang.String r6 = android.os.Build.VERSION.SDK     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b0, all -> 0x009d }
            byte[] r6 = r6.getBytes()     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b0, all -> 0x009d }
            r5.zzgm = r6     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b0, all -> 0x009d }
            byte[] r9 = r9.getBytes()     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b0, all -> 0x009d }
            r5.zzgl = r9     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b0, all -> 0x009d }
            com.google.android.gms.internal.zzcx r9 = r7.zzait     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b0, all -> 0x009d }
            byte[] r6 = r7.zzaiu     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b0, all -> 0x009d }
            java.lang.String r8 = r9.zzc(r6, r8)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b0, all -> 0x009d }
            byte[] r8 = r8.getBytes()     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b0, all -> 0x009d }
            r5.data = r8     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b0, all -> 0x009d }
            byte[] r8 = com.google.android.gms.internal.zzbx.zzb(r8)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b0, all -> 0x009d }
            r5.zzgk = r8     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b0, all -> 0x009d }
            r0.createNewFile()     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b0, all -> 0x009d }
            java.io.FileOutputStream r8 = new java.io.FileOutputStream     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b0, all -> 0x009d }
            r8.<init>(r0)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b0, all -> 0x009d }
            byte[] r9 = com.google.android.gms.internal.zzfls.zzc(r5)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x009b, all -> 0x0098 }
            int r0 = r9.length     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x009b, all -> 0x0098 }
            r8.write(r9, r4, r0)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x009b, all -> 0x0098 }
            r8.close()     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x009b, all -> 0x0098 }
            r3.close()     // Catch:{ IOException -> 0x0091 }
        L_0x0091:
            r8.close()     // Catch:{ IOException -> 0x0094 }
        L_0x0094:
            zzb(r1)
            return
        L_0x0098:
            r9 = move-exception
            r2 = r8
            goto L_0x00a1
        L_0x009b:
            r2 = r8
            goto L_0x00b0
        L_0x009d:
            r9 = move-exception
            goto L_0x00a1
        L_0x009f:
            r9 = move-exception
            r3 = r2
        L_0x00a1:
            if (r3 == 0) goto L_0x00a6
            r3.close()     // Catch:{ IOException -> 0x00a6 }
        L_0x00a6:
            if (r2 == 0) goto L_0x00ab
            r2.close()     // Catch:{ IOException -> 0x00ab }
        L_0x00ab:
            zzb(r1)
            throw r9
        L_0x00af:
            r3 = r2
        L_0x00b0:
            if (r3 == 0) goto L_0x00b5
            r3.close()     // Catch:{ IOException -> 0x00b5 }
        L_0x00b5:
            if (r2 == 0) goto L_0x00ba
            r2.close()     // Catch:{ IOException -> 0x00ba }
        L_0x00ba:
            zzb(r1)
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.internal.zzdm.zza(java.io.File, java.lang.String):void");
    }

    /* access modifiers changed from: private */
    public static boolean zza(int i, zzba zzba) {
        if (i >= 4) {
            return false;
        }
        if (zzba == null) {
            return true;
        }
        if (((Boolean) zzlc.zzio().zzd(zzoi.zzbrv)).booleanValue() && (zzba.zzcv == null || zzba.zzcv.equals("0000000000000000000000000000000000000000000000000000000000000000"))) {
            return true;
        }
        if (((Boolean) zzlc.zzio().zzd(zzoi.zzbrw)).booleanValue()) {
            return zzba.zzfh == null || zzba.zzfh.zzgf == null || zzba.zzfh.zzgf.longValue() == -2;
        }
        return false;
    }

    /* access modifiers changed from: private */
    public final void zzao() {
        try {
            if (this.zzaiv == null && this.zzaix) {
                AdvertisingIdClient advertisingIdClient = new AdvertisingIdClient(this.zzaiq);
                advertisingIdClient.start();
                this.zzaiv = advertisingIdClient;
            }
        } catch (GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException | IOException unused) {
            this.zzaiv = null;
        }
    }

    @VisibleForTesting
    private final zzba zzap() {
        try {
            return zzcda.zzm(this.zzaiq, this.zzaiq.getPackageName(), Integer.toString(this.zzaiq.getPackageManager().getPackageInfo(this.zzaiq.getPackageName(), 0).versionCode));
        } catch (Throwable unused) {
            return null;
        }
    }

    private static void zzb(File file) {
        if (!file.exists()) {
            Log.d(TAG, String.format("File %s not found. No need for deletion", new Object[]{file.getAbsolutePath()}));
            return;
        }
        file.delete();
    }

    /* JADX WARNING: Can't wrap try/catch for region: R(8:29|30|31|32|33|34|35|36) */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:34:0x00b1 */
    /* JADX WARNING: Removed duplicated region for block: B:52:0x00c7 A[SYNTHETIC, Splitter:B:52:0x00c7] */
    /* JADX WARNING: Removed duplicated region for block: B:56:0x00cc A[SYNTHETIC, Splitter:B:56:0x00cc] */
    /* JADX WARNING: Removed duplicated region for block: B:64:0x00d3 A[SYNTHETIC, Splitter:B:64:0x00d3] */
    /* JADX WARNING: Removed duplicated region for block: B:68:0x00d8 A[SYNTHETIC, Splitter:B:68:0x00d8] */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private final boolean zzb(java.io.File r10, java.lang.String r11) {
        /*
            r9 = this;
            java.io.File r0 = new java.io.File
            java.lang.String r1 = "%s/%s.tmp"
            r2 = 2
            java.lang.Object[] r3 = new java.lang.Object[r2]
            r4 = 0
            r3[r4] = r10
            r5 = 1
            r3[r5] = r11
            java.lang.String r1 = java.lang.String.format(r1, r3)
            r0.<init>(r1)
            boolean r1 = r0.exists()
            if (r1 != 0) goto L_0x001b
            return r4
        L_0x001b:
            java.io.File r1 = new java.io.File
            java.lang.String r3 = "%s/%s.dex"
            java.lang.Object[] r2 = new java.lang.Object[r2]
            r2[r4] = r10
            r2[r5] = r11
            java.lang.String r10 = java.lang.String.format(r3, r2)
            r1.<init>(r10)
            boolean r10 = r1.exists()
            if (r10 == 0) goto L_0x0033
            return r4
        L_0x0033:
            r10 = 0
            long r2 = r0.length()     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d0, all -> 0x00c3 }
            r6 = 0
            int r8 = (r2 > r6 ? 1 : (r2 == r6 ? 0 : -1))
            if (r8 > 0) goto L_0x0042
            zzb(r0)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d0, all -> 0x00c3 }
            return r4
        L_0x0042:
            int r2 = (int) r2     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d0, all -> 0x00c3 }
            byte[] r2 = new byte[r2]     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d0, all -> 0x00c3 }
            java.io.FileInputStream r3 = new java.io.FileInputStream     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d0, all -> 0x00c3 }
            r3.<init>(r0)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d0, all -> 0x00c3 }
            int r6 = r3.read(r2)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            if (r6 > 0) goto L_0x005e
            java.lang.String r11 = TAG     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            java.lang.String r1 = "Cannot read the cache data."
            android.util.Log.d(r11, r1)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            zzb(r0)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            r3.close()     // Catch:{ IOException -> 0x005d }
        L_0x005d:
            return r4
        L_0x005e:
            com.google.android.gms.internal.zzbe r6 = new com.google.android.gms.internal.zzbe     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            r6.<init>()     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            com.google.android.gms.internal.zzfls r2 = com.google.android.gms.internal.zzfls.zza(r6, r2)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            com.google.android.gms.internal.zzbe r2 = (com.google.android.gms.internal.zzbe) r2     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            java.lang.String r6 = new java.lang.String     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            byte[] r7 = r2.zzgl     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            r6.<init>(r7)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            boolean r11 = r11.equals(r6)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            if (r11 == 0) goto L_0x00ba
            byte[] r11 = r2.zzgk     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            byte[] r6 = r2.data     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            byte[] r6 = com.google.android.gms.internal.zzbx.zzb(r6)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            boolean r11 = java.util.Arrays.equals(r11, r6)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            if (r11 == 0) goto L_0x00ba
            byte[] r11 = r2.zzgm     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            java.lang.String r6 = android.os.Build.VERSION.SDK     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            byte[] r6 = r6.getBytes()     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            boolean r11 = java.util.Arrays.equals(r11, r6)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            if (r11 != 0) goto L_0x0093
            goto L_0x00ba
        L_0x0093:
            com.google.android.gms.internal.zzcx r11 = r9.zzait     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            byte[] r0 = r9.zzaiu     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            java.lang.String r6 = new java.lang.String     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            byte[] r2 = r2.data     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            r6.<init>(r2)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            byte[] r11 = r11.zzb(r0, r6)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            r1.createNewFile()     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            java.io.FileOutputStream r0 = new java.io.FileOutputStream     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            r0.<init>(r1)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            int r10 = r11.length     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b8, all -> 0x00b5 }
            r0.write(r11, r4, r10)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00b8, all -> 0x00b5 }
            r3.close()     // Catch:{ IOException -> 0x00b1 }
        L_0x00b1:
            r0.close()     // Catch:{ IOException -> 0x00b4 }
        L_0x00b4:
            return r5
        L_0x00b5:
            r11 = move-exception
            r10 = r0
            goto L_0x00c5
        L_0x00b8:
            r10 = r0
            goto L_0x00d1
        L_0x00ba:
            zzb(r0)     // Catch:{ zzcy | IOException | NoSuchAlgorithmException -> 0x00d1, all -> 0x00c1 }
            r3.close()     // Catch:{ IOException -> 0x00c0 }
        L_0x00c0:
            return r4
        L_0x00c1:
            r11 = move-exception
            goto L_0x00c5
        L_0x00c3:
            r11 = move-exception
            r3 = r10
        L_0x00c5:
            if (r3 == 0) goto L_0x00ca
            r3.close()     // Catch:{ IOException -> 0x00ca }
        L_0x00ca:
            if (r10 == 0) goto L_0x00cf
            r10.close()     // Catch:{ IOException -> 0x00cf }
        L_0x00cf:
            throw r11
        L_0x00d0:
            r3 = r10
        L_0x00d1:
            if (r3 == 0) goto L_0x00d6
            r3.close()     // Catch:{ IOException -> 0x00d6 }
        L_0x00d6:
            if (r10 == 0) goto L_0x00db
            r10.close()     // Catch:{ IOException -> 0x00db }
        L_0x00db:
            return r4
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.internal.zzdm.zzb(java.io.File, java.lang.String):boolean");
    }

    private static void zzm(String str) {
        zzb(new File(str));
    }

    public final Context getContext() {
        return this.zzaiq;
    }

    public final ExecutorService getExecutorService() {
        return this.zzair;
    }

    public final boolean isInitialized() {
        return this.zzaje;
    }

    public final Method zza(String str, String str2) {
        zzes zzes = this.zzajd.get(new Pair(str, str2));
        if (zzes == null) {
            return null;
        }
        return zzes.zzbb();
    }

    /* access modifiers changed from: package-private */
    @VisibleForTesting
    public final void zza(int i, boolean z) {
        if (this.zzajc) {
            Future<?> submit = this.zzair.submit(new zzdo(this, i, z));
            if (i == 0) {
                this.zzaiz = submit;
            }
        }
    }

    public final boolean zza(String str, String str2, Class<?>... clsArr) {
        if (this.zzajd.containsKey(new Pair(str, str2))) {
            return false;
        }
        this.zzajd.put(new Pair(str, str2), new zzes(this, str, str2, clsArr));
        return true;
    }

    public final int zzab() {
        if (this.zzaja != null) {
            return zzcp.zzab();
        }
        return Integer.MIN_VALUE;
    }

    public final DexClassLoader zzaf() {
        return this.zzais;
    }

    public final zzcx zzag() {
        return this.zzait;
    }

    public final byte[] zzah() {
        return this.zzaiu;
    }

    public final boolean zzai() {
        return this.zzajb;
    }

    public final zzcp zzaj() {
        return this.zzaja;
    }

    public final boolean zzak() {
        return this.zzajc;
    }

    public final boolean zzal() {
        return this.zzajf;
    }

    public final zzba zzam() {
        return this.zzaiy;
    }

    public final Future zzan() {
        return this.zzaiz;
    }

    public final AdvertisingIdClient zzaq() {
        if (!this.zzahq) {
            return null;
        }
        if (this.zzaiv != null) {
            return this.zzaiv;
        }
        if (this.zzaiw != null) {
            try {
                this.zzaiw.get(2000, TimeUnit.MILLISECONDS);
                this.zzaiw = null;
            } catch (InterruptedException | ExecutionException unused) {
            } catch (TimeoutException unused2) {
                this.zzaiw.cancel(true);
            }
        }
        return this.zzaiv;
    }

    /* access modifiers changed from: package-private */
    @VisibleForTesting
    public final zzba zzb(int i, boolean z) {
        if (i > 0 && z) {
            try {
                Thread.sleep((long) (i * 1000));
            } catch (InterruptedException unused) {
            }
        }
        return zzap();
    }
}
